package zjh_20230316;

public class Demo01 {
    public static void main(String[] args) {
        int size = 0,sum = 0;
        String str = "aabbccdaa";
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < str.length() - 1; i++) {
            char c = str.charAt(i);
            char c2 = str.charAt(i + 1);
            if (c2 != c ){
                String newstr = str.substring(sum - size,i);
                size = newstr.length() - size;
                sum += size;
                s.append(c);
                s.append(size);
            }
        }
        System.out.println(s.toString());
    }
}
